package nccloud.rongq.bill.rongqvo.action;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.alibaba.fastjson.JSONObject;

import nc.itf.uap.IUAPQueryBS;
import nc.jdbc.framework.processor.MapListProcessor;
import nc.vo.pub.BusinessException;
import nccloud.framework.service.ServiceLocator;
import nccloud.framework.web.action.itf.ICommonAction;
import nccloud.framework.web.container.IRequest;

public class TableEvenRongQVO implements ICommonAction {

	@Override
	public Object doAction(IRequest request) {
		
		String read = request.read();
		JSONObject jsonObject = JSONObject.parseObject(read);
		
		String editKey = jsonObject.getString("editKey");
		String data = jsonObject.getString("data");
		
		Map<String, Object> result = new HashMap<String, Object>();
		
		result.put("key", result);
		
		switch (editKey) {
		case "def1":
			accbankAfter(data,result);
			break;
		case "def6":
			defbankAfter(data,result);
			break;
		default:
			break;
		}
		return result;	
	}
	private void accbankAfter(String pk_defdoc,Map<String, Object> result) {
		String sql = "select code from bd_defdoc where pk_defdoc='"+pk_defdoc+"'";
		try {
			List<Map<String, Object>> list = (List<Map<String, Object>>) ServiceLocator.find(IUAPQueryBS.class).executeQuery(sql,new MapListProcessor());
			
			result.put("key", list.get(0).get("code"));
		} catch (BusinessException e) {
			e.printStackTrace();
		}
	}
	
	private void defbankAfter(String data,Map<String, Object> result) {
		String sql = "select code from bd_defdoc where pk_defdoc='"+data+"'";
		try {
			List<Map<String, Object>> list = (List<Map<String, Object>>) ServiceLocator.find(IUAPQueryBS.class).executeQuery(sql,new MapListProcessor());
			
			result.put("key", list.get(0).get("code"));
		} catch (BusinessException e) {
			e.printStackTrace();
		}
	}
}
